package com.ruoyi.system.execute;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName LoadCacheManager
 * @Description
 * @Author sizegang
 * @Date2025/4/19 22:08
 **/
@Component
public class LoadCacheManager implements InitializingBean {
    /**
     * hg_KhdAppId:
     * hg_KhdAppSecret:
     * <p>
     * hg_ygdAppId:
     * hg_ygdAppSecret:
     */

    @Value("${wxLogin.hg_KhdAppId}")
    private String hg_KhdAppId;
    @Value("${wxLogin.hg_KhdAppSecret}")
    private String hg_KhdAppSecret;

    @Value("${wxLogin.hg_ygdAppId}")
    private String hg_ygdAppId;
    @Value("${wxLogin.hg_ygdAppSecret}")
    private String hg_ygdAppSecret;

    public static final Map<String, String> WX_LOGIN_CACHE = new ConcurrentHashMap<>();


    @Override
    public void afterPropertiesSet() {
        loadWxCache();
    }

    private void loadWxCache() {
        WX_LOGIN_CACHE.put("hg_khdAppId", hg_KhdAppId);
        WX_LOGIN_CACHE.put("hg_khdAppSecret", hg_KhdAppSecret);
        WX_LOGIN_CACHE.put("hg_ygdAppId", hg_ygdAppId);
        WX_LOGIN_CACHE.put("hg_ygdAppSecret", hg_ygdAppSecret);
    }
}
